﻿
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="../layui/css/layui.css" media="all">
<link rel="stylesheet" href="css/myCss.css">
<script src="../layui/layui.js" charset="utf-8"></script>
<script src="js/jquery-1.12.4.js" type="text/javascript"></script>
<script type="text/javascript">
    function getUrlParam(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
        var r = window.location.search.substr(1).match(reg);  //匹配目标参数
        if (r != null) return unescape(r[2]); return null; //返回参数值
    }
    //获取图片真实宽高
    function getImageWidth(url, callback) {
        var img = new Image();
        img.src = url;

        // 如果图片被缓存，则直接返回缓存数据
        if (img.complete) {
            callback(img.width, img.height);
        } else {
            // 完全加载完毕的事件
            img.onload = function () {
                callback(img.width, img.height);
            }
        }
    }
</script>
 
    <script type="text/javascript">
        layui.use(['form'], function () {
            var form = layui.form();
            form.render();
            $("#myaddClick").click(function () {
                $("#add").show();
                $(".addList").hide();
            });
        });
        
        function deleteB(myId) {//单个删除
              var index = parent.layer.confirm('你确定要删除吗？', {
                  btn: ['删除', '我再想想'] //按钮
              }, function () {
                  parent.layer.close(index);
                  location.href = 'G_links.html?id=' + myId + "&action=del";
              }, function () {
                  parent.layer.close(index);
              });
        }
    </script>
</head>
<body>
    <a class='layui-btn addList'  id="myaddClick"><i class="layui-icon">
        &#xe61f;</i> 添加链接<!--href="G_links.html?action=tab1"--></a>
    <div style="display:none;" id="add">
        <blockquote class="layui-elem-quote" >
            添加友情链接</blockquote>
        <form class="layui-form" action="?action=add" method="post">
        <input type="hidden" id="leix" name="leix" value="2" />
        <div class="layui-form-item">
            <label class="layui-form-label">
                网站名</label>
            <div class="layui-input-block">
                <input type="text" name="txtG_name" value="" lay-verify="required"
                    placeholder="请输入网站名" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                链接地址</label>
            <div class="layui-input-block">
                <input type="text" name="txtG_address" value="" lay-verify="url"
                    class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">
                链接排序</label>
            <div class="layui-input-inline">
                <input type="number" name="txtG_sorting" value="" lay-verify="number"
                    placeholder="请输入链接排序" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" lay-submit>
                    立即添加</button>
                <button type="reset" class="layui-btn layui-btn-primary">
                    重置</button>
            </div>
        </div>
        </form>
    </div>
    <table lay-even class="layui-table addList" lay-skin="line" >
        <thead>
            <tr>
                <th>
                    网站名
                </th>
                <th>
                    链接地址
                </th>
                <th>
                    链接排序
                </th>
                <th>
                    操作
                </th>
            </tr>
        </thead>
        <tbody>
           
            <tr>
                <td>
                    baidu
                </td>
                <td>
                    http://www.baidu.ocm/
                </td>
                <td>
                    1
                </td>
                <td>
                    <a href="G_links.html?id=2&action=tab1" class="layui-btn layui-btn-mini"
                        title="修改"><i class="layui-icon">&#xe642;</i></a> <a title="删除" onclick="deleteB(2)"
                            class="layui-btn layui-btn-mini layui-btn-danger"><i class="layui-icon">&#xe640;</i></a>
                </td>
            </tr>
            
        </tbody>
    </table>
</body>
</html>
